<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var findMinDifference = function (timePoints) {
      timePoints.sort()
      let minDiff = getDiff(timePoints[1], timePoints[0]);
      for (let i = timePoints.length - 1; i >= 0; i--) {
        let diff
        if (i === 0) {
          diff = getDiff(timePoints[i], timePoints[timePoints.length - 1])
          if (diff < minDiff) {
            minDiff = diff
          }
          return minDiff
        }
        diff = getDiff(timePoints[i], timePoints[i - 1])
        if (diff < minDiff) {
          minDiff = diff
        }
      }
    };
    function getDiff(time1, time2) {
      let minute1, minute2;
      let arr1 = time1.split(':')
      let arr2 = time2.split(':')
      minute1 = arr1[0] * 60 + Number(arr1[1])
      minute2 = arr2[0] * 60 + Number(arr2[1] * 1)

      if ((minute1 - minute2) >= 0) { return minute1 - minute2 }
      else {
        minute1 = (Number(arr1[0]) + 24) * 60 + Number(arr1[1])
        return minute1 - minute2
      }
    }
    console.log(findMinDifference(["00:00", "23:59"]))
  </script>
</body>

</html>